extends "../calxJS_Hide/calxJS_Hide.gd"
func _init():
	pass
func _extInit():
	._extInit()
	chaName = "小教皇"                   # 角色的名称
	attCoe.atkRan = 2                 # 攻击距离
	attCoe.maxHp = 4.5                  # 最大生命（每点代表112.5基础数值，取整数，下同）
	attCoe.atk = 3                    # 攻击力（每点代表8.5）
	attCoe.mgiAtk = 7                 # 魔法攻击（每点代表13.7）
	attCoe.def = 3.5                    # 物理防御（每点代表15）
	attCoe.mgiDef = 4.5                 # 魔法防御（每点代表16.6）
	atkEff = "atk_dang" 
	xb = "王"
	lv = 3   
	addSkillTxt("[警世先兆]推出警世的光球攻击目标单体，造成160%神秘系魔法伤害，30%让目标<警觉>5秒[CD:7]")
	addSkillTxt("[净化之杖]净化世间邪恶，杖击目标单体，造成130%王系魔法伤害，提升10%魔攻，最高60%\n若目标身上有异常状态，则再提升一次[CD:12]")
	addSkillTxt("[生息圣堂]<先发><唯一>10秒内我方全体亚比至少保留1点体力，效果结束时恢复教皇魔攻*1的体力值[CD:20]")
	addSkillTxt("[color=#CC0000]杀戮过多的话似乎会发生不好的事情[/color]")
	addCdSkill("jsxz",7)
	addCdSkill("jhzz",12)
	addCdSkill("sxst",15)

func _castCdSkill(id):
	._castCdSkill(id)
	if id == "jsxz":
		var d:Eff = newEff("sk_feiDang",sprcPos)
		d._initFlyCha(aiCha)
		yield(d,"onReach")
		typeHurtCha(aiCha,att.mgiAtk*1.6,Chara.HurtType.MGI,Chara.AtkType.SKILL)
		if sys.rndPer(30):
			aiCha.addBuff(jingshi.new(5))
	if id == "jhzz":
		var eff = sys.newEff("numHit", position, false, 1)
		eff.setText("净化之杖", "#FF0099")
		eff.anim.set_speed_scale(0.2)
		typeHurtCha(aiCha,att.mgiAtk*1.3,Chara.HurtType.MGI,Chara.AtkType.SKILL)
		var b = hasBuff("mogong1")
		if b == null:
			addBuff(bf.mogong1.new())
		elif b.att.mgiAtkL < 0.6:
			b.att.mgiAtkL += 0.1
		for j in aiCha.buffs:
			if not j.isNegetive && j.get("type") != config.EQUITYPE_EQUI && j.get("dispelable") != true:
				j.isDel = true
				if b == null:
					addBuff(bf.mogong1.new())
				elif b.att.mgiAtkL < 0.6:
					b.att.mgiAtkL += 0.1
	if id == "sxst":
		sxst()

func _onBattleStart():
	._onBattleStart()
	sxst()

func sxst():
	var eff = sys.newEff("numHit", position, false, 1)
	eff.setText("生息圣堂", "#FF0099")
	eff.anim.set_speed_scale(0.2)
	var chas = getAllChas(2)
	for i in chas :
		if i.hasBuff("sxst1"):break
		i.addBuff(sxst1.new(10))
		var bf:Buff = i.hasBuff("sxst1")
		if bf!=null:bf.damage=max(att.mgiAtk*1,bf.damage)

class sxst1:
	extends Buff
	var damage=0
	func _init(lv=1,fire=1):
		._init()
		attInit()
		life=lv
		damage=max(fire,damage)
		id = "sxst1"
		isNegetive=false
		var dispelable = true
	func _connect():
		masCha.connect("onHurt",self,"onHurt")
	func onHurt(atkInfo:AtkInfo):
		if atkInfo.hurtVal >= masCha.att.hp:
			masCha.att.hp = 1
			atkInfo.hurtVal = 0
	func _del():
		masCha.plusHp(damage*1)


class jingshi:
	extends Buff
	func _init(lv = 1):
		attInit()
		life = lv
		isNegetive=true
		var dispelable = false
		id = "jingshi"	
		att.defR = +0.15
	func _upS():
		for i in masCha.skills: i.nowTime = 0


func _onBattleEnd():
	._onBattleEnd()
	var bese=globalData.infoDs["g_weiyi"]
	if bese.aoxilisi == 0:return
	if killNum > 50:
		bese.aoxilisi -= 1
		yield(reTimer(0.1),"timeout")
		sys.newBaseMsg("信念转变","冥界之主在指引我！我将舍弃众生！")
		sys.main.player.addCha(sys.main.newChara("cex___aoxilisi"))
		deleteSelf()

func deleteSelf():
	var node = self.get_parent()
	sys.main.delMatChara(self)
	if node != null and self.isItem:
		node.queue_free()